<template>
  <h2>我是About组件</h2>
</template>

<script>
export default {
    name:"About",
    mounted() {

    },
    beforeDestroy() {
      // 路由在被切换掉后实际上默认被销毁了！
      console.log("About路由被销毁")
    },
    // 组件路由守卫beforeRouteEnter 会在进入该组件路由后调用
    beforeRouteEnter (to, from, next) {
      console.log("beforeRouteEnter---"+to.name);
      if(to.meta.isAuth){
          if(localStorage.getItem('school')=="atguigu"){
              // console.log("学校名正确，放行");
              next();
          }else{
              alert('学校名不对，跳转失败')
          }
      }else{
          // console.log("不需要检测学校名的路由组件");
          next()
      }
    },
    beforeRouteLeave (to, from, next) {
      console.log("beforeRouteLeave---"+to.name);
      next();
    }
}
</script>

<style>

</style>